package com.csaba.db.connection;


/**
 * This interface must be implemented in order to get DB connection. This is used to keep the
 * database up-to-date and initialized for each plugin. 
 * @author Gabe
 * XXX this could be an extension point. 
 */
public interface DBConsumer
{
	/**
	 * This method defines the version of the data consumer. If the database tables/structure of 
	 * the consumer plugin has changed, the version of the consumer must be increased.
	 * @return database version of the consumer plugin 
	 */
	public int getVersion();
	
	
	/**
	 * This method is invoked if the database plugin founds that database doesn't contain tables for 
	 * this plugin. This method is responsible for initializing the db. * 
	 * 
	 * @return init SQL script of the consumer plugin
	 */
	public String getInitScript();
	
	
	
	/**
	 * This method is invoked if the plugin was initialized in the database, however the 
	 * current version is older than the current plugin version. (old version < current version)
	 * @param oldVersion
	 * @return migration SQL script from the old version to the current version.
	 */
	public String getMigrationScript( int oldVersion );
}
